package com.sskj.gcc.market.dialog;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sskj.gcc.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import razerdp.basepopup.BasePopupWindow;

/**
 * 更多k线弹框
 *
 * @author Hey
 */
public class MorePopupWindow extends BasePopupWindow {

    @BindView(R.id.minute)
    TextView minute;
    @BindView(R.id.minute_5)
    TextView minute5;
    @BindView(R.id.minute_30)
    TextView minute30;
    @BindView(R.id.minute_week)
    TextView minuteWeek;
    @BindView(R.id.minute_month)
    TextView minuteMonth;

    private View rootView;

    public MorePopupWindow(Context context) {
        super(context);
        minute.setOnClickListener(v -> {
            if (mListener != null) {
                mListener.onClick(this, "minute", minute.getText().toString());
            }
        });
        minute5.setOnClickListener(v -> {
            if (mListener != null) {
                mListener.onClick(this, "minute5", minute5.getText().toString());
            }
        });
        minute30.setOnClickListener(v -> {
            if (mListener != null) {
                mListener.onClick(this, "minute30", minute30.getText().toString());
            }
        });
        minuteWeek.setOnClickListener(v -> {
            if (mListener != null) {
                mListener.onClick(this, "week", minuteWeek.getText().toString());
            }
        });
        minuteMonth.setOnClickListener(v -> {
            if (mListener != null) {
                mListener.onClick(this, "month", minuteMonth.getText().toString());
            }
        });
    }

    @Override
    public View onCreateContentView() {
        rootView = createPopupById(R.layout.market_more_popupwindos);
        ButterKnife.bind(this, rootView);
        return rootView;
    }

    public interface OnClickListener {
        void onClick(MorePopupWindow popupWindow, String type, String name);
    }


    private OnClickListener mListener;


    public void setListener(OnClickListener mListener) {
        this.mListener = mListener;
    }
}
